package com.IntelligentCommunity.system.service.impl;

import com.IntelligentCommunity.common.core.utils.StringUtils;
import com.IntelligentCommunity.system.mapper.SysUserDistrictMapper;
import com.IntelligentCommunity.system.service.ISysUserDistrict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 用户小区权限业务层
 * @author 美国五星上将麦克阿瑟
 */
@Service
public class SysUserDistrictImpl implements ISysUserDistrict {

    @Autowired
    private SysUserDistrictMapper districtMapper;

    @Override
    public Set<String> selectDistrictIdsByUserId(Long userId) {
        List<String> perms = districtMapper.selectDistrictIdsByUserId(userId);
        Set<String> permsSet = new HashSet<>();
        for (String perm : perms)
        {
            permsSet.addAll(Arrays.asList(perm.trim().split(",")));
        }
        return permsSet;
    }
}
